package net.huashitong.scheduling.dao;

import java.util.List;

import com.sirdc.modules.core.filter.BaseFilter;
import org.springframework.stereotype.Repository;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;

import net.huashitong.scheduling.entity.TownshipCondition;
import net.huashitong.scheduling.filter.ProjectFilter;

@Repository
public class TownshipConditionDao extends StringDao<TownshipCondition>{
	
	public TownshipCondition queryByName(ProjectFilter filter){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.name = :name").setParam("name",filter.getName());
		query.setOrder("date+0", BaseFilter.DESC);
		return query.firstResult();
	}
	public List<TownshipCondition> queryList(String date){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.date =:date order by cast(obj.ratio*100 as int) DESC ").setParam("date", date);
		return query.listResult();
	}
	
}
